|
|
2019
|
|||||||||
Autores: |
|||||||||||
|
Michele Gaiarin (Nº 1190274) |
1190274@isep.ipp.pt |
|||||||||
|
Antonio Domingos Dias Santos (Nº 1171178) |
1171178@isep.ipp.pt
|
|||||||||
|
|||||||||||
|
|||||||||||
The request made for this project was to obtain a system capable of mapping a room, determining the distance of objects and walls
from where the assessment is made. Furthermore, the system must be able to create a 2D map with the measures toke and to show them
visually via the graphical interface.
State of the ArtSonar, (from "sound navigation ranging"), technique for detecting and determining the distance and direction of underwater objects by acoustic means. Sound waves emitted by or reflected from the object are detected by sonar apparatus and analyzed for the information they contain [1]. SONAR applications in mappingLet`s see some example of application already made. Ultrasonic Cave MappingThis study uses a novel method based on ultrasound reflections to produce an accurate 3D model of Kitley Shelter Cave [Figure 1], an archaeological cave in Yealmpton, Devon. This model enables the cave system to be visualized leading to a better understanding of the site and its taphonomy. [2] A number of options are available for automatically calculating the distance of an object from a point. [3]The most accurate systems use electromagnetic radiation (either radar or laser sources). [2] Laser sources are highly dependent on the precise reflective properties of the target object and are unsuitable when used on rough, bare rock surfaces. [2] Radar is considerably better, but suitable equipment is neither cheap nor easily portable. Sound waves are a suitable alternative for range finding where exact precision is not required. [4] Ultrasound transducers are relatively inexpensive, and usually ultrasound beams reflect well off rock surfaces. The lack of precision is due to the difficulty in obtaining a narrow ultrasound beam and the problem of shaping a precisely defined sound pulse. Implemented prototypesUltrasonic Map-Maker using an Arduino Yun [5]
Project developed and implemented by Satyavrat Wagle, makes use of the HC-SR04 ultrasonic
sensor to map the surrounding environment.
The sensor is attached to a servo motor (Tower Pro SG90) that makes it spin, all the while the
Arduino Yun controls the motion of the servo motor [Figure 2].
The process of data from the sensor and subsequent plotting of the graphical map [Figure 3]. is
achieved by using Mathworks MatLab. |
|||||||||||
|
|||||||||||
Sonar Architecture SchemaBlocks descriptionAtmega 328p:The microcontroller deals with :
Motor:The motor rotates the sensor during data acquisition. Every 5,625° (Every 64 steps) set the flag to enable the measurement through sonar. During the measurement it maintains the current position and starts to rotate again after the data has been sent to the PC. Sonar:Sonar is provided by the microcontroller via the PIN trigger, which must remain set for at least 15us. After sonar is enabled set the echo PIN and send the signal. When the signal goes back and hits the receiver it resets the echo PIN. CP2102:
CP2102 is used to receive the start measurement signal (the character 'A') from the PC (via interrupt).
When this character is read room mapping begins. PC side:On the PC side through a program developed in Python it is possible to create the serial connection with the microcontroller. Once the connection is established, is possible to send the signal to start the measurement. Subsequently, the program takes care of reading the strings received from the serial port. The position and distance data are extracted from the string using regular expressions that eliminate special characters and save all the data in a list, which will then be used to create the map via the python library: "matplotlib.pyplot" |
|||||||||||
|
|||||||||||
The whole system requires a current consumption of 280mA. You will now see in detail all the components used. Microcontroller: atmega328pThe ATmega328 is a 8-bit AVR microcontroller created by Atmel (now part of Microchip Technology Inc.) in the megaAVR family. Among other features, the ATmega328p has 32 kilobytes (kB) of program memory size, 1kB EEPROM, 2kB SRAM, 27 general purpose I/O lines, 32 general purpose working registers, five flexible timer/counters with compare modes, internal and external interrupts, two USARTs, two byte-oriented 2-wire serial interfaces, two SPI serial ports, 8-channel 10-bit A/D converter[6]. The most common implementation of this chip is in the Arduino development boards, used mostly by hobbyist and in educational embedded applications. SONAR: HC-SR04 sensor
The HCSR04 ultrasonic sensor uses sonar to determine distance to an object.
This module provides 2cm to 400cm measurement function, ranging accuracy of 3mm and a maximum angle at which objects are positioned and still retrieve an accurate measure (effectual angle) of 15°.
The modules includes ultrasonic transmitters, receiver and control circuit.
The ultrasonic distance measurement principle works as followed: when enabled, the ultrasonic transmitter of the module sends an ultrasonic pulse train (eight 40 kHz pulses) in one direction, which returns to the ultrasonic receiver when it encounters an obstacle in its way.
Considering the velocity of sound constant (340 m/s), the information about the distance is strictly pertained to the elapsed time. With a known elapsed time, the distance of the object can be calculated using the formula:[7] Motor: 28byj-48 stepper motor
Stepper motors are a special type of brushless motors that divides a full rotation into a number of equal steps. They are usually found in desktop printers, 3D printers, CNC milling machines, DVD players, and anything else that requires precise positioning control.
Stepper motors will move only one step at a time. These motors have a sequence of coils present in them and these coils have to be energized in a particular fashion to make the motor rotate. When each coil is being energized the motor takes a step and a sequence of energization will make the motor take continuous steps, thus making it to rotate.
The 28byj-48 stepper moto has a 4 coil unipolar arrangement and each coil is connected to a constant +5V supply. The coil will only be active if the other end of the coil is grounded. A stepper motor can be made to rotate only if the coils are energized (grounded) in a logical sequence. This logical sequence will be programmed using a microcontroller.
This motor has a speed variation ratio of 1/64, which means that the shaft on the outside will make one complete rotation only if the motor inside rotates for 64 times. This is because of the gears that are connected between the motor and output shaft and these gears help in increasing the torque.
When working in half-step mode, this motor has a stride angle of 5.625°/64, so it will have to make 64 steps to complete one rotation and for every step it will cover a 5.625°.
The power consumption of the motor is around 240mA. Motor driver: ULN2003The ULN2003A is a high voltage, high current Darlington arrays each containing seven open collector common emitter pairs. Each pair is rated at 500mA. [datasheet reference] A Darlington transistor configuration is an array of bipolar transistors pairs, connected in such a way that the current amplified by the first transistor is amplified further by the second one [x]. The motor that is used in this project consumes high current, so a driver is needed to be able to control the motor with a microcontroller. As mentioned previously, the Darlington configuration present in this IC driver allows for high current output with low current and voltage prevenient from the microcontroller[10][11]. Programmer: USBaspThe AVR USBasp is a USB in-circuit programmer that can use to program most of the Atmel AVR controllers. It simply consists of an ATMega8 and a couple of passive components such as resistors, capacitors, LEDs and ect. The programmer uses a firmware only USB driver and there is no special USB controller is needed. By using AVR USBasp, it is easier and simpler, it just needs one step to finish the process which is to connect the AVR USBasp with computer and with microcontroller, then program it.[datasheet reference] The module has 3.3V and 5V double voltage supports, with 500mA over current protection re settable fuse to prevent damage to the computer USB port connected with[12]. USB to TTL converter: CP2102
The CP2102 is a highly-integrated USB-to-UART Bridge Controller, made by Silicon Laboratories, providing a simple solution for updating RS-232 designs to USB.[datasheet reference]
The embedded system converts the differential D+ and D- signals of the USB interface in to RX and TX signals of the RS232 interface and this output is TTL (transistor-transistor logic) compatible.
This TTL is the method of serial communication used by UART.
The USB interface can run with lower input and supply voltages, but the RS232 output will be TTL level (between ground and 3.3V) [13][14]. PCBModule schematics: |
|||||||||||
|
|||||||||||
Flow chart schemaFunctions descriptionInitialization
Initializzation: Here is possible to see al the functions used for initilize the Atmega328p with all the
comment for undestand better wht every function do.
ISR(USART_RX_vect) : When receve an interrupt from the USART check the data. If the data is the character 'A' then reset the flags "interrupt_counter" and "last_step" also enable the Timer0.
ISR(TIMER0_COMPA_vect) :When an interrupt occurs modify the motor's coil configuration to the next step.
ISR(TIMER0_COMPB_vect) : Return the engine to the initial position through an inverse rotation with respect to the one in which the measurements were taken. It also checks every time if the original position has been reached. If the condition is verified, it changes the comparator of Timer0 and set the flag "last_step" to indicate that the position has been reached. ISR(TIMER1_OVF_vect) : Whenever there is an overflow in the counter of Timer1 it increases the value of the flag "TimerOverflow".
Distance_Measurement() : This function takes care of enabling sonar through the PIN Trigger. Send_Data() : The purpose of this function is to convert the data obtained from the measurement in strings. Then concatenate everything to get a string in the format "degreeValueString;distanceValueString\n". Finally send the string obtained using the USART_SendString () function which takes care of sending strings through the USART taking advantage of the USART_TxChar function which sends single characters through the USART. Main : The main program continuously checks whether the "activate_sonar" and "last_step" are respectively set and reset. If the condition has occurred :
Send_Data() : The purpose of this function is to convert the data obtained from the measurement in strings. Then concatenate everything to get a string in the format "degreeValueString;distanceValueString\n". Finally send the string obtained using the USART_SendString () function which takes care of sending strings through the USART taking advantage of the USART_TxChar function which sends single characters through the USART. Python program : In the PC side the program was made with Python3. The program is a class capable of creating a simple graphical interface, with which it is possible :
Motor position and measured distance values are extracted from the string using regular expressions that eliminate special characters and divide the string in two using the symbol as separator ";" previously inserted by the microcontroller. Once obtained, the data are converted from string to float and saved in two lists. Finally the values in the lists are plotted using the Python library "matplotlib.pyplot" showing the polar plot and displaying the results achieved. |
|||||||||||
|
|||||||||||
|
|||||||||||
|
|||||||||||
Objectives evaluation:The objectives proposed were as followed: to make a system able of mapping a room, determining the distance of objects and walls from where the assessment is made, and furthermore present a 2D map with the measures toke and to show them visually via the graphical interface. The main scope of this system was achieved, never the less with some limitations. In theory, the implemented system is not able to map a room bigger then 4mx4m because of the technical limitations imposed by the HC-SR04 that has a maximum range of 4m, although that the best results obtained by this system where within the area of 2mx2m. SONAR unreliabilityThe sonar module HC-SR04 was the most limiting factor of this system. As specified in the datasheet, this module works best when operating with flat surfaces. As presented in the following demonstration, this system shows good results when working with flat surfaces and even accompanies the change of distance of said surface with good results. When operating in an environment with irregular surfaces and changing angles of incidence of the ultrasonic waves as this system requires, this module can present inaccurate results, resulting in abnormal values considering the area in question. An implemented solution to this problem was an application of the Kalman filter algorithm. This algorithm uses a series of measurements observed over time, with inaccurate readings, and makes estimates that tend to be more accurate than single measurements, in which results a smoothing of the plotting of the single point readings. Although this method provides some improvements over the single result analyses, it is prone to fail when the system encounters big disparity between successive angles, as in wrong readings by the SONAR. Bluetooth implementationA tested upgrade for the system was the substitution of the USART to serial converter for the Bluetooth module HC-05. The implementation of this module plus batteries would allow for a wireless connection to the exterior of the system. After various trials with this module it was reached the conclusion that this method of communication was less reliable than the wired one, as it sometimes would work as intended and some other times, many followed successful attempts, would not transmit data to the PC. The problem is it could derive directly from that specific component, having also shown problems relating to the power supply being unable to turn on and having continuous disconnections. As we were not able to find an explanation and solution for this problem, this upgrade was scraped from the final version. Batteries implementationAs mention previously, the implementation of the Bluetooth module plus batteries would allow for a wireless connection to the exterior of the system. This implementation was tested with two 9V alkaline batteries rated as 500 mAh, connected in parallel to the entrance of a LM7805 voltage regulator circuit. There were used two batteries to increase the lifetime of each one. This implementation was scrapped because of the problem encountered with the Bluetooth module, making this way of powering the circuit redundant. |
|||||||||||
|
|||||||||||
[1] The Editors of Encyclopaedia Britannica, “Sonar,” [Online]. Available : https://www.britannica.com/technology/sonar .[Acessed in 14 10 2019]. [2] W. I. Sellers e A. T. Chamberlain, "Ultrasonic Cave Mapping", Journal of Archaeological Science, vol. 25, no 9, p. 867–873, 1998. [3] D. Gibson, "Electronics in surveying," Journal of the BCRA Cave Radio and Electronics Group, 25, no 9, p. 867–873, 1998. [4] D. Gibson, "Accuracy problems in ultrasonic and light-beam," Journal of the BCRA Cave Radio and Electronics, vol. 6, p. 9, 1991. [5] S. Wagle, "Ultrasonic Map-Maker using an Arduino Yun GPL3+", [Online]. Available : https://create.arduino.cc/projecthub/Satyavrat/ultrasonic-map-maker-using-an-arduino-yun-37c72e. [Acessed in 16 10 2019]. [6]
www.microchip.com,
" Atmega328p", [Online]. Available
https://www.microchip.com/wwwproducts/en/ATmega328PB].
[7] Sprakfun, " HC-Sr04 datasheet", [Online]. Available https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf]. [8] CircuitDigest, " What is stepper motor and how it works;, [Online]. Available https://circuitdigest.com/tutorial/what-is-stepper-motor-and-how-it-works]. [Acessed in 01 10 2018]. [9] Components 101, " 28BYJ-48 datasheet", [Online]. Available https://components101.com/sites/default/files/component_datasheet/28byj48-step-motor-datasheet.pdf]. [10] CircuitDigest, " Interfacing Stepper Motor with AVR Microcontroller Atmega16;, [Online]. Available https://circuitdigest.com/microcontroller-projects/avr-microcontroller-atmega16-stepper-motor-interfacing]. [Acessed in 19 02 2019]. [11] www.diodes.com, " ULN200xA datasheet", [Online]. Available https://www.diodes.com/assets/Datasheets/ULN200xA.pdf]. [12] www.hmangas.com, " AVR-USBasp datasheet", [Online]. Available http://www.hmangas.com/Electronica/Datasheets/USBasp/AVR-USBasp%20User%20Manual.pdf]. [13] haoyuelectronics, " Schematic CP2102;, [Online]. Available http://www.haoyuelectronics.com/ebay/CP2102_module/USB-to-UART_SCH.pdf]. [14] Sparkfun, " CP2102 datasheet", [Online]. Available https://www.sparkfun.com/datasheets/IC/cp2102.pdf]. Images:[1] W. I. Sellers e A. T. Chamberlain, "Ultrasonic Cave Mapping", Journal of Archaeological Science, vol. 25, n°r; 9, p. 867–873, 1998. [2] S. Wagle, "Ultrasonic Map-Maker using an Arduino Yun © GPL3+", [Online]. Available https://create.arduino.cc/projecthub/Satyavrat/ultrasonic-map-maker-using-an-arduino-yun-37c72e]. [Acessed in 16 10 2019]. [3] S. Wagle, "Ultrasonic Map-Maker using an Arduino Yun GPL3+", [Online]. Available https://create.arduino.cc/projecthub/Satyavrat/ultrasonic-map-maker-using-an-arduino-yun-37c72e ]. [Acessed in 16 10 2019]. [5] robu.in "Atmega328p", [Online]. Available https://robu.in/product/atmega328p-pu-pdip-28-microcontroller/ ]. [6] SparkFun "HC-SR04", [Online]. Available https://www.sparkfun.com/products/15569]. [7] tme.eu "Step motor 28BYJ-48-5V", [Online]. Available https://www.tme.eu/pt/details/mikroe-1530/acessorios-para-sistemas-de-arranque/mikroelektronika/step-motor-5v-28byj-48-5v/?brutto=1¤cy=EUR&gclid=Cj0KCQiAxrbwBRCoARIsABEc9shSBB61nzwQ0og35DTMAXy7Xw6ExHQApseDQ_aQFrAYEkzhI-nsolsaAio9EALw_wcB ]. [8] ptrobotics.com "ULN2003", [Online]. Available https://www.ptrobotics.com/circuitos-integrados-varios/1575-uln2003-7-channel-darlington-driver.html?gclid=Cj0KCQiAxrbwBRCoARIsABEc9siddhJYzubNVIZb_jKAyO_8FiJttzhOnB8O9pfJesiBc9sc82zqMWMaAiWFEALw_wcB ]. [9] https://www.banggood.com/ "USBasp", [Online]. Available https://www.banggood.com/pt/3_3V-5V-USBASP-USBISP-AVR-Programmer-Downloader-ATMEGA8-ATMEGA128-With-Download-Cable-p-1179967.html?gmcCountry=PT¤cy=EUR&createTmp=1&utm_source=googleshopping&utm_medium=cpc_bgs&utm_content=lijing&utm_campaign=ssc-pt-all-july&ad_id=353642503365&gclid=Cj0KCQiAxrbwBRCoARIsABEc9sjz_goVF26y90hW2PpTJntGKnZRFsaDgkunzcqmzUZ1By8pzjclwbAaAvTjEALw_wcB&cur_warehouse=CN ].
|
|||||||||||
|